#include <WinTen.h>
#include <Windows.h>
#include <CommDlg.h>
#include <ClipApi.h>

#define LF_HEIGHT          1
#define LF_WIDTH           2
#define LF_ESCAPEMENT      3
#define LF_ORIENTATION     4
#define LF_WEIGHT          5
#define LF_ITALIC          6
#define LF_UNDERLINE       7
#define LF_STRIKEOUT       8
#define LF_CHARSET         9
#define LF_OUTPRECISION   10
#define LF_CLIPPRECISION  11
#define LF_QUALITY        12
#define LF_PITCHANDFAMILY 13
#define LF_FACENAME       14

CLIPPER ChooseFONT()
{
   LOGFONT    lf;
   CHOOSEFONT cf;
   BOOL       bOk;

   _bset( ( BYTE * ) &cf, 0, sizeof( cf ) );

   cf.lStructSize = sizeof( CHOOSEFONT );
   cf.hwndOwner   = GetActiveWindow();
   cf.lpLogFont   = &lf;
   cf.Flags       = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS;
   cf.rgbColors   = RGB( 0, 0, 0 );
   cf.nFontType   = PRINTER_FONTTYPE;

   bOk = ChooseFont( &cf );
   _reta( 14 );

   _storni( bOk ? lf.lfHeight:         0, -1, LF_HEIGHT );
   _storni( bOk ? lf.lfWidth:          0, -1, LF_WIDTH );
   _storni( bOk ? lf.lfEscapement:     0, -1, LF_ESCAPEMENT );
   _storni( bOk ? lf.lfOrientation:    0, -1, LF_ORIENTATION );
   _storni( bOk ? lf.lfWeight:         0, -1, LF_WEIGHT );
   _storl(  bOk ? lf.lfItalic:         0, -1, LF_ITALIC );
   _storl(  bOk ? lf.lfUnderline:      0, -1, LF_UNDERLINE );
   _storl(  bOk ? lf.lfStrikeOut:      0, -1, LF_STRIKEOUT );
   _storni( bOk ? lf.lfCharSet:        0, -1, LF_CHARSET );
   _storni( bOk ? lf.lfOutPrecision:   0, -1, LF_OUTPRECISION );
   _storni( bOk ? lf.lfClipPrecision:  0, -1, LF_CLIPPRECISION );
   _storni( bOk ? lf.lfQuality:        0, -1, LF_QUALITY );
   _storni( bOk ? lf.lfPitchAndFamily: 0, -1, LF_PITCHANDFAMILY );
   _storc(  bOk ? lf.lfFaceName:      "", -1, LF_FACENAME );
}
